package com.gzy.rpsm_admin.controller;

import com.gzy.rpsm_admin.pojo.Floor;
import com.gzy.rpsm_admin.pojo.PageResult;
import com.gzy.rpsm_admin.pojo.ResponsePojo;
import com.gzy.rpsm_admin.service.FloorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "楼层相关接口")
public class FloorController {
    @Autowired
    private FloorService floorService;
    @GetMapping("/page/floor")
    @ApiOperation(value = "查询楼层分页信息",
    response = Floor.class,
    responseContainer = "list",
    produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({    // 参数加入文档说明
            @ApiImplicitParam(name="current",value = "当前页数 ",defaultValue = "1",dataType = "Integer",paramType = "query"),
            @ApiImplicitParam(name="size",value = "页面行数",dataType = "Integer",paramType = "query",defaultValue = "10"),
            @ApiImplicitParam(name="number",value="楼层编号",dataType = "String",paramType = "query")
    })


    // 其中请求中的current和size参数会被解析后赋值给下面函数中的current和size参数
    public ResponsePojo<PageResult<Floor>> pageOfFloor(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size,
            String number){ //  接收query中的number参数，传递给service层使用
        PageResult<Floor> floors = floorService.pageOfFloor(current,size,number);
        return ResponsePojo.success(floors);
}
}
